package base.src;

import game.base.BaseCanvas;
import game.base.BaseFrame;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.MotionEvent;

public class FrameWaitingFellow extends BaseFrame {
	float angle = 0;
	public FrameWaitingFellow(BaseCanvas father, float _x, float _y, float _width, float _height) {
		super(father, _x, _y, _width, _height);
	}
	
	@Override
	public void onDraw(Canvas canvas) {
		Paint p = new Paint();
		p.setColor(Color.BLACK);
		canvas.drawRect(getX(), getY(), getX() + getWidth(), getY() + getHeight(), p);
		p.setColor(Color.WHITE);
		p.setTextSize(40);
		canvas.drawText("Waiting for player", getX() + getWidth() * .5f - 160, getY() + 35, p);
		canvas.save();
		canvas.translate(getX() + getWidth() * .5f, getY() + getHeight() * .5f);
		canvas.rotate(angle);
		canvas.translate(-(getX() + getWidth() * .5f), -(getY() + getHeight() * .5f));
		canvas.drawBitmap(Images.progressBar.getImage(), getX() + getWidth() * .5f - Images.progressBar.getWidth() * .5f, getY()
				+ getHeight() * .5f - Images.progressBar.getHeight() * .5f, p);
		canvas.restore();
	}
	
	@Override
	public void onUpdate(long difftime) {
		angle = (angle + 20) % 360;
	}
	
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		BaseCanvas father = getFather();
		((GameScreen) father).startDeploying();
		return false;
	}
	
}
